<template>
  <div>
    <p class="title">推荐歌单</p>
    <van-grid :border="false" :column-num="3">
      <van-grid-item v-for="item in recommendList" :key="item.id">
        <van-image :src="item.picUrl" />
        <p class="song_name">{{ item.name }}</p>
      </van-grid-item>
    </van-grid>
    <p class="title">最新音乐</p>
    <van-cell
      v-for="item in newMusicList"
      :key="item.id"
      :title="item.name"
      :label="`${item.song.artists[0].name} - ${item.name}`"
      ><img src="../Play/img/start.png" class="imagesPlay"
    /></van-cell>
  </div>
</template>

<script>
import { recommendMusicListApi, newMusicListApi } from '@/api'
export default {
  data() {
    return {
      recommendList: [],
      newMusicList: [],
    }
  },
  async created() {
    const { data: res1 } = await recommendMusicListApi({ limit: 6 })
    const { data: res2 } = await newMusicListApi({ limit: 30 })
    console.log(res1, res2)
    if (res1.code !== 200 || res2.code !== 200)
      return this.$notify({ type: 'danger', message: '获取失败' })
    this.$notify({ type: 'success', message: '获取成功' })
    this.recommendList = res1.result
    this.newMusicList = res2.result
  },
}
</script>

<style scoped>
/* 标题 */
.title {
  padding: 0.266667rem 0.24rem;
  background-color: #eee;
  color: #333;
  font-size: 15px;
}
/* 推荐歌单 - 歌名 */
.song_name {
  font-size: 0.346667rem;
  padding: 0 0.08rem;
  margin-bottom: 0.266667rem;
  word-break: break-all;
  text-overflow: ellipsis;
  display: -webkit-box; /** 对象作为伸缩盒子模型显示 **/
  -webkit-box-orient: vertical; /** 设置或检索伸缩盒对象的子元素的排列方式 **/
  -webkit-line-clamp: 2; /** 显示的行数 **/
  overflow: hidden; /** 隐藏超出的内容 **/
}
.van-cell {
  border-bottom: 0.0125rem solid lightgray;
  display: flex;
  align-items: center;
}
.imagesPlay {
  width: 0.9rem;
}
</style>
